import React from 'react';

const ThemeContext = React.createContext({a:'a', b: 'b'});

class Button extends React.Component {
  componentDidMount() {
    // ThemeContext value is this.props.theme
  }

  componentDidUpdate(prevProps, prevState) {
    // Previous ThemeContext value is prevProps.theme
    // New ThemeContext value is this.props.theme
  }

  render() {
    const {theme, children} = this.props;
    console.log(this.props)
    return (
      <button className={theme ? 'dark' : 'light'}>
        {children}
      </button>
    );
  }
}

const Theme = ()=>{
  <ThemeContext.Provider value={'test'}>
    <div>测试</div>
  </ThemeContext.Provider>
}

console.log(Theme())

export default props => (
  <ThemeContext.Consumer>
    {
      theme => <div>
        {Theme()}
        <Button {...props} {...theme} tt={'aa'} />
      </div>
    }
  </ThemeContext.Consumer>
);


//
// export default class TablePage extends React.Component {
// }